In [1]:
import lib.operations as operations
from lib.schemas import *
from lib.subjectRepresentations import *
from lib.textRepresentations import *
from lib.paths import *
from lib.dataManager import *
from lib.optionsFactory import *
In [2]:
schema1=Schema("PoissonEF","PoissonEI",operations.addition,"PoissonGAIN","change")
schema2=Schema("ViandeEF","ViandeEI",operations.addition,"ViandeGAIN","change")
struct=ProblemStructure()
struct.addSchema(schema1)
struct.addSchema(schema2)
struct.addBridgingSchemas(schema1,schema2)
struct.updateObjectSet()
text=Text()
text.addTextInformation(TextInformation(Representation(Quantity("PoissonGAIN","P1"),'Au supermarché, le kilo de poisson a augmenté de 5 euros cette année')))
text.addTextInformation(TextInformation(Representation(Quantity("PoissonEF","T1"),'Un kilo de poisson coute maintenant 12 euros.')))
text.addTextInformation(TextInformation(Representation(Quantity("PoissonEIminusViandeEI","dEI"),'Au début de l\'année, le kilo de viande coutait le même prix que le kilo de poisson.')))
text.addTextInformation(TextInformation(Representation(Quantity("PoissonGAINminusViandeGAIN","d"),'Le kilo de viande a augmenté de 3 euros de moins que le kilo de poisson')))
text.setGoal(TextGoal(Goal('ViandeEF','Combien coute le kilo de viande maintenant?')))
text.getTextInformation(0).addAlternativeRepresentation(Representation(Quantity("PoissonEI","P1"),'Au supermarché, le kilo de poisson était de 5 euros'))
text.getTextInformation(0).addAlternativeRepresentation(Representation(Quantity("PoissonEF","P1"),'Au supermarché, le kilo de poisson coute 5 euros'))
text.getTextInformation(1).addAlternativeRepresentation(Representation(Quantity("PoissonEI","T1"),'Un kilo de poisson était de 12 euros.'))
text.getTextInformation(2).addAlternativeRepresentation(Representation(Quantity("PoissonEFminusViandeEF","dEI"),'Au la fin de l\'année, le kilo de viande coute le même prix que le kilo de poisson.'))
text.getTextInformation(2).addAlternativeRepresentation(Representation(Quantity("PoissonGAINminusViandeGAIN","dEI"),'Le kilo de viande a augmenté du même prix que le kilo de poisson.'))
text.getTextInformation(3).addAlternativeRepresentation(Representation(Quantity("ViandeGAIN","d"),'Le kilo de viande a augmenté de 3 euros'))
text.getTextInformation(3).addAlternativeRepresentation(Representation(Quantity("ViandeGAIN","-d"),'Le kilo de viande a diminué de 3 euros'))
text.getTextInformation(3).addAlternativeRepresentation(Representation(Quantity("PoissonGAINminusViandeGAIN","-d"),'Le kilo de viande a augmenté de 3 euros de plus que le kilo de poisson'))
text.getTextInformation(3).addAlternativeRepresentation(Representation(Quantity("PoissonEFminusViandeEF","d"),'Le kilo de viande vaut 3 euros de moins que le kilo de poisson'))
text.getTextInformation(3).addAlternativeRepresentation(Representation(Quantity("PoissonEFminusViandeEF","-d"),'Le kilo de viande vaut 3 euros de plus que le kilo de poisson'))
text.getTextInformation(3).addAlternativeRepresentation(Representation(Quantity("ViandeEF","d"),'Le kilo coute 3 euros à la fin'))
probleme1=Problem(struct,text)
In [3]:
problem2=copy.deepcopy(probleme1)
problem3=copy.deepcopy(probleme1)
In [4]:
renameDic={'PoissonEF': 'PoissonEFsecond',
'PoissonEI': 'PoissonEIsecond',
'PoissonGAIN': 'PoissonGAINsecond',
'ViandeEF': 'ViandeEFsecond',
'ViandeEI': 'ViandeEIsecond',
'ViandeGAIN': 'ViandeGAINsecond',
'PoissonGAINminusViandeGAIN' : 'PoissonGAINminusViandeGAIN_second',
'PoissonEIminusViandeEI' : 'PoissonEIminusViandeEI_second',
'PoissonEFminusViandeEF' : 'PoissonEFminusViandeEF_second'
}
In [5]:
problem2.renameObjects(renameDic)
print(problem2.structure.objectSet)
In [6]:
for ti in problem2.text.textInformations:
for rep in ti.representations:
print(rep.quantity.object)
In [7]:
keydic={"Poisson":"Morue","Viande":"Cerf"}
problem3.renameKeywordObjects(keydic)
In [8]:
print(problem3.structure.objectSet)
In [9]:
for s in problem3.structure.schemas:
print(s.objects)
In [10]:
for ti in problem3.text.textInformations:
for rep in ti.representations:
print(rep.quantity.object)
In [11]:
problem3.setInitialValues({"P1":5,"T1":12,"dEI":0,"d":3,"-d":-3})
problem3.name="Tc4t"
Let see if the solving process still works
problem2
In [12]:
upD=Updater(problem2)
upD.startAsUnderstood()
c1=IntervalConstraint(['EF','EI'],operations.superiorOrEqualTo0)
c2=BehavioralConstraint(breakTheOldOne=True)
constraints=[c1,c2]
autoSolver=Solver(upD,constraints)
l=[autoSolver.SOLVER]
autoSolver.generalSequentialSolver(listOfActions=l)
autoSolver.TreePaths.scanTree()
print(autoSolver.TreePaths.treeOutput)
In [13]:
problem3
Out[13]:
In [14]:
upD=Updater(problem3)
upD.startAsUnderstood()
c1=IntervalConstraint(['EF','EI'],operations.superiorOrEqualTo0)
c2=BehavioralConstraint(breakTheOldOne=True)
constraints=[c1,c2]
autoSolver=Solver(upD,constraints)
l=[autoSolver.SOLVER]
autoSolver.generalSequentialSolver(listOfActions=l)
autoSolver.TreePaths.scanTree()
print(autoSolver.TreePaths.treeOutput)
In [14]: